package ray;

import ray.math.*;
import ray.surface.*;


public class Ray {

	// Tiny number for floating point computation comparisons
	public static final double TINY = 1e-6;
	
	public final Point3 origin = new Point3();
    public final Vector3 direction = new Vector3();
    
    //start and end of the t value, to avoid shading issues
    public double tStart = TINY;
    public double tEnd = Double.POSITIVE_INFINITY;
    
    Surface object;
	
	public Ray(Point3 eye, Vector3 dir) {
		
		origin.set(eye);
		
		direction.set(dir);
		direction.normalize();
	}

	public Ray() {
		// default constructor
	}

	public void set(Point3 newEye, Vector3 newDir){
		
		origin.set(newEye);
		direction.set(newDir);
		direction.normalize();
	}
	
	// Sets the input point to a point on the ray, dist from the origin
	
	public void getPoint(Point3 point, double dist){
		
		point.set(origin);
		point.scaleAdd(dist, direction);
	}
}
